<?php

/**
 * This is the model class for table "car_prices".
 *
 * The followings are the available columns in table 'car_prices':
 * @property integer $id
 * @property string $car_type
 * @property string $car_name
 * @property string $dong_co
 * @property string $hop_so
 * @property string $cong_suat
 * @property string $momen_xoan
 * @property string $price
 */
class CarPrices extends CActiveRecord
{
    const AUDI = 'Audi';
    const HYUNDAI = 'Hyundai';
    const HONDA = 'Honda';
    const TOYOTA = 'Toyota';
    const MAZDA = 'Mazda';
    const MERCEDES = 'Mercedes-Benz';
    const LEXUS = 'Lexus';
    const KIA = 'KIA';
    const LAND_ROVER = 'Land Rover';
    const MINI = 'MINI';
    const FORD = 'Ford';
    const CHEVROLET = 'Chevrolet';
    const BMW = 'BMW';
    const MITSUBISHI = 'Mitsubishi';
    const NISSAN = 'Nissan';
    const PORSCHE = 'Porsche';
    const RENAULT = 'Renault';
    const SUBARU = 'Subaru';
    const SUZUKI = 'Suzuki';
    const VOLKSWAGEN = 'Volkswagen';
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return CarPrices the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'car_prices';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('car_type, car_name', 'required'),
			array('car_type, car_name, dong_co, hop_so, cong_suat, momen_xoan', 'length', 'max'=>100),
			array('price', 'length', 'max'=>50),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, car_type, car_name, dong_co, hop_so, cong_suat, momen_xoan, price', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'car_type' => 'Car Type',
			'car_name' => 'Car Name',
			'dong_co' => 'Dong Co',
			'hop_so' => 'Hop So',
			'cong_suat' => 'Cong Suat',
			'momen_xoan' => 'Momen Xoan',
			'price' => 'Price',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('car_type',$this->car_type,true);
		$criteria->compare('car_name',$this->car_name,true);
		$criteria->compare('dong_co',$this->dong_co,true);
		$criteria->compare('hop_so',$this->hop_so,true);
		$criteria->compare('cong_suat',$this->cong_suat,true);
		$criteria->compare('momen_xoan',$this->momen_xoan,true);
		$criteria->compare('price',$this->price,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}